﻿using Ascend;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Media3D;

namespace Demo02_LoadingModels
{
	/// <summary>
	/// Interaction logic for MainWindow.xaml
	/// </summary>
	public partial class MainWindow : Window
	{
		#region Lifecycle
		public MainWindow()
		{
			InitializeComponent();

			// Set data context for bindings
			DataContext = this;

			// Create our Scene3D object
			Scene = new Scene3D();

			// Setup the camera
			Scene.Camera.Position = new Point3D(-2, 2.0, 3.5);
			Scene.LookAt(new Point3D(-0.25, 0, 0));

			// Load a hierarchical bird model that consists of a
			// parent bird and two child birds.
			// 
			// Each will be loaded as a separate scene node,
			// preserving the original parent-child relationships
			// that existed when the model was first exported
			// from Blender.
			//
			// The model file must be accessible at runtime, so
			// the file contains a property specifying that it
			// be copied to the output directory when the project
			// is built (right-click 'birds.asc' in solution -> Properties).
			ModelSceneNode parentBird = Loader.Load<ModelSceneNode>("Models\\birds.asc");
			parentBird.Parent = Scene.RenderRoot;

			// Now add a light, so objects can be seen
			LightSceneNode light =
				LightSceneNode.Create(new DirectionalLight(Colors.White, new Vector3D(0, -1, -2)));
			light.Parent = Scene.RenderRoot;
		}
		#endregion

		#region Public Properties
		/// <summary>
		/// Gets the Scene3D that is rendered.
		/// </summary>
		public Scene3D Scene
		{
			get;
			private set;
		}
		#endregion
	}
}
